import GameControl from "./GameControl";
import { StorageName } from "./StorageName";

export default class H5Api {
    // 单例模式
    private static _instance: H5Api = null;
    public static getInstance() {
        if (this._instance == null) {
            this._instance = new H5Api();
        }
        return this._instance;
    }

    // 初始化
    init() { }

    // 登录
    login() {
        return new Promise<any>((resolve, reject) => {
            printLog('H5登录');
            if (GameControl.getInstance().getLocalStorage(StorageName.GAME_DATA)) {
                resolve({ "status": true, "data": GameControl.getInstance().getLocalStorage(StorageName.GAME_DATA) });
            } else {
                resolve({ "status": false, "data": null });
            }
        })
    }

    // banner广告
    createBannerAd() {
        return;
    }

    // 销毁广告
    hideBarAd() {
        return;
    }

    // 激励视频
    initVideoAd() {
        return new Promise<any>((resolve, reject) => {
            resolve(true);
        })
    }

    // 播放视频
    playVideoAd() {
        return new Promise<any>((resolve, reject) => {
            resolve({
                status: true,
                msg: '播放完成'
            });
        })
    }

    // 长震动
    vibrateLong() {
        return;
    }

    // 短震动
    vibrateShort() {
        return;
    }

    //开始录屏
    StartRecordScreen() {
        return;
    }

    // 停止录屏
    StopRecordScreen() {
        return;
    }

    // 分享录屏
    ShareRecordScreen() {
        return new Promise<any>((resolve, reject) => {
            resolve(true);
        });
    }

    // 插屏
    interstitialAd(callback) {
        callback(true);
        // return new Promise<any>((resolve, reject) => {
        //     resolve(true);
        // })
    }

    // 主动分享
    shareAppMessage() {
        return new Promise<any>((resolve, reject) => {
            resolve({
                status: true,
                msg: '分享成功'
            })
        })
    }
}